package com.bwie.service.impl;

import com.bwie.common.domain.Goods;
import com.bwie.common.domain.response.GoodsResp;
import com.bwie.common.result.PageResult;
import com.bwie.mapper.GoodsMapper;
import com.bwie.service.GoodsService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @className: GoodsServiceImpl
 * @Description: TODO
 * @version: v1.８.0
 * @author: 郑伦
 * @date: 2025/7/31 10:30
 */
@Service
public class GoodsServiceImpl implements GoodsService {

    @Autowired
    GoodsMapper goodsMapper;

    @Override
    public PageResult<Goods> goodsList(GoodsResp goodsResp) {
        PageHelper.startPage(goodsResp.getPageNum(),goodsResp.getPageSize());
        List<Goods> goodsList = goodsMapper.goodsList(goodsResp);
        PageInfo<Goods> goodsPageInfo = new PageInfo<>(goodsList);
        PageResult<Goods> goodsPageResult = PageResult.toPageResult(goodsPageInfo.getTotal(), goodsList);
        return goodsPageResult;
    }
}